package com.twohand.admin.Controller;

import com.twohand.admin.Annotation.Permission;
import com.twohand.admin.Dto.SwipeListQueryDto;
import com.twohand.admin.Entity.Swipe;
import com.twohand.admin.Service.SwipeService;
import com.twohand.admin.Util.PageResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/swipe")
public class SwipeController {
    @Autowired
    SwipeService swipeService;
    @Permission(value = "swipe:list")
    @GetMapping
    PageResponse<Swipe> getSwipeList(SwipeListQueryDto swipeListQueryDto){
        return swipeService.getAllSwipe(swipeListQueryDto);
    }

    @Permission(value = "swipe:add")
    @PostMapping
    Boolean insert(@RequestBody Swipe swipe){
        return swipeService.addSwipe(swipe);
    }

    @Permission(value = "swipe:edit")
    @PutMapping
    Boolean update(@RequestBody Swipe swipe){
        return swipeService.updateSwipe(swipe);
    }

    @Permission(value = "swipe:delete")
    @DeleteMapping("/{id}")
    Boolean del(@PathVariable Integer id){
        return swipeService.delSwipe(id);
    }
}
